<?php

class Router {
    public static function getController() {
        if(isset($_GET['module'])) {
            $module = new Module((int)$_GET['module']);
            if($module->getMid() <= 0) {
                $_GET['action'] = 'wrongModule';
                return new main_Controller();
            } else {
                $ctrl = $module->getDir() . '_Controller';
                return new $ctrl();
            }
        } else {
            return new main_Controller();
        }
    }
    
    public static function getAction() {
        if(isset($_GET['action'])) {
            return $_GET['action'];
        } else {
            return '_default';
        }
    }
    
    public static function getParams() {
        $params = $_GET;
        $_GET = array();
        return $params;
    }
}

?>
